package com.yimils.core.goods.controller;

import com.yimils.core.common.dto.RspBase;
import com.yimils.core.goods.dto.HotelTypeAddReq;
import com.yimils.core.goods.dto.HotelTypeUpdateReq;
import com.yimils.core.goods.serivce.HotelTypeService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Validated
public class HotelTypeController {
    @Resource(name = "hotelTypeService")
    HotelTypeService hotelTypeService;


    @PostMapping("/hotelTy/save")
    public RspBase saveHotelType(@RequestBody HotelTypeAddReq hotelTypeAddReq) {
        if (hotelTypeService.saveHotelType(hotelTypeAddReq)) {
            return RspBase.OK("成功");
        }
        return RspBase.OK("失败");
    }


    @PutMapping("/hotelTy/update")
    public RspBase updateHotelType(@RequestBody HotelTypeUpdateReq hotelTypeUpdateReq) {
        if (hotelTypeService.updateHotelType(hotelTypeUpdateReq)) {
            return RspBase.OK("成功");
        }
        return RspBase.OK("失败");
    }

    @DeleteMapping("/hotelTy/delete")
    public RspBase deleteHotelType(List<Long> hotelTypeIds) {
        if (hotelTypeService.deleteHotelType(hotelTypeIds)) {
            return RspBase.OK("成功");
        }
        return RspBase.OK("失败");
    }

    @GetMapping("/hotelTy/list")
    public RspBase listHotelType() {
        RspBase rsp = RspBase.OK();
        rsp.put("data", hotelTypeService.listHotelType());
        return rsp;
    }

}
